package com.example.demo.config;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

import java.util.HashMap;
import java.util.Map;

@Configuration
@ConfigurationProperties(prefix = "myapp.users")
public class UserConfig {
    private HashMap<String, OUser> userMap =   new HashMap<>();

    public Map<String, OUser> getUsers() {
        return userMap;
    }

    public void setUsers(Map<String, OUser> users) {
        this.userMap = (HashMap<String, OUser>) users;
    }

    public Map<String, OUser> getUserMap() {
        return userMap;
    }
    public String getUserScore() {
        System.out.println("getUserScore " + userMap);
        return userMap.toString();
    }


    @Override
    public String toString() {
        return "UserConfiguration{" +
                "users=" + userMap +
                '}';
    }


    public static class OUser {
        private String name;
        private int age;

        // Getters and setters

        @Override
        public String toString() {
            return "User{" +
                    "name='" + name + '\'' +
                    ", age=" + age +
                    '}';
        }
    }



}
